package com.lizhi.yun.core.game;/**
 * @program: hbsf_yun
 * @name RszGameHandler
 * @description:
 * @author: lizhi
 * @create: 2021-11-03 14:09
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.mybatis.interceptor.PageBounds;
import com.lizhi.utils.StringUtils;
import com.lizhi.utils.json.SamJsonUtil;
import com.lizhi.yun.db.rsz.dao.RszGameTrainDao;
import com.lizhi.yun.db.rsz.dao.RszPatientDao;
import com.lizhi.yun.db.rsz.entity.RszGameTrainEntity;
import com.lizhi.yun.db.rsz.entity.RszPatientEntity;
import com.lizhi.yun.deploy.NewBaseHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 *@program: hbsf_yun
 *@name RszGameHandler
 *@description:
 *@author: lizhi
 *@create: 2021-11-03 14:09
 */
@Slf4j
@Service
public class RszGameTrainHandler extends NewBaseHandler {

    @Resource
    private RszGameTrainDao rszGameTrainDao;

    @Resource
    private RszPatientDao rszPatientDao;

    /**
     *功能描述 根据游戏记录id查询
     * @author lizhi
     * @date 2021/11/3
     * @param json:
     * @return com.lizhi.common.yun.entity.ListResponseResult
     */
    public ListResponseResult doMain(String json){
        Map<String, Object> map = SamJsonUtil.toMap(json);
        PageBounds pageBounds = getPageBounds(map);
        List<RszGameTrainEntity> rszGameTrainEntities = rszGameTrainDao.selectByMap(map, pageBounds);
        for (RszGameTrainEntity rszGameTrainEntity : rszGameTrainEntities){
            RszPatientEntity rszPatientEntity = rszPatientDao.selectById(rszGameTrainEntity.ptId, rszGameTrainEntity.hospitalId, rszGameTrainEntity.hospitalSystemId);
            if (!StringUtils.isEmpty(rszPatientEntity)){
                rszGameTrainEntity.rszPatientEntity = rszPatientEntity;
            }
        }
        return getListResult(pageBounds.getCountRows(), rszGameTrainEntities, map);
    }
}
